import router from '@/router'

export default {
  namespaced: true,
  state: {
    userName: '',
    userCode: '',
    userHeadImgUrl: '',
    userIsPhone: '',
    dingName: '',
    dingUserId: '',
    dingUserInfo: '',
    dingCode: ''
  },
  mutations: {
    setUserData (state, payload) {
      state.userName = payload.empname
      state.userCode = payload.empcode
      state.userHeadImgUrl = payload.empprofileimageurl
      console.log('setUserData------------>', state, payload)
      if (state.userIsPhone) {
        router.replace('/MobileHomeView').catch (err => { console.log(err) })
      } else {
        router.replace('/tablePage').catch(err => { console.log(err) })
      }
    },
    setDingUserData (state, payload) {
      state.dingName = payload.name
      state.dingUserId = payload.userid
    },
    setUserIsPhone (state, payload) {
      state.userIsPhone = payload
    },
    setCode (state, payload) {
      state.dingCode = payload
    },
    logOut (state) {
      state.userName = ''
      state.userCode = ''
      state.userHeadImgUrl = ''
      state.dingName = ''
      state.dingUserId = ''
      state.dingUserInfo = ''
      state.dingCode = ''
    }
  },
  actions: {}
}